How to solve segmentation fault in c